//
//  GLGWPopTosView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/11.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "GLGWPopTosView.h"

@interface GLGWPopTosView ()

@property (nonatomic, strong) GLGWLabel *tosStringLabel;
@property (nonatomic, strong) GLGWImageView *topImageView;

@end

@implementation GLGWPopTosView


- (id)initWithPopView:(PopViewType)p_type
{
    if (self = [super initWithFrame:kAppWindow.bounds inSuperView:kAppWindow]) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];//145
        GLGWView *centerView = [[GLGWView alloc] initWithInSuperView:self];
        centerView.backgroundColor = [UIColor colorWithHexString:@"#000000"];
        centerView.layer.cornerRadius = 6.0;
        centerView.layer.masksToBounds = YES;
        [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(120)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(93)));
        }];
        
        self.topImageView = [[GLGWImageView alloc] initInSuperView:centerView];
        self.topImageView.backgroundColor = kRandomColor;
        if (p_type == PopViewType_Success) {
//            self.topImageView.imageName = @"";
        } else {
            
        }
        [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(centerView);
            make.top.equalTo(centerView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(21));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(20)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        
        self.tosStringLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor whiteColor] inSuperView:centerView];
        [self.tosStringLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(centerView);
            make.top.equalTo(self.topImageView.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(18));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        
        centerView.transform = CGAffineTransformMakeScale(0.8f, 0.8f);
        [UIView animateWithDuration:0.2 animations:^{
            centerView.transform = CGAffineTransformIdentity;
        } completion:^(BOOL finished) {
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [self removeFromSuperview];
            });
        }];
    }
    return self;
}

- (void)setTosTitle:(NSString *)tosTitle
{
    _tosTitle = tosTitle;
    self.tosStringLabel.text = _tosTitle;
}


@end
